/**
 * Created by Administrator on 2017/5/22.
 */
import  axIos  from 'axios';
import {stackToken,setToken} from '../comm/commom';
axIos.defaults.timeout = 1000 * 15; //发送的超时时间
const http = {
  methods: {
    apiPost(url, data){
      return new Promise((resolve, reject) => {
        setToken(axIos);
        axIos.post(url, data).then((response) => {
          stackToken(response);
          resolve(response);
        }).catch((response) => {
          reject(response);
        })
      })
    }
    , apiGet(url, data){
      return new Promise((resolve, reject) => {
        setToken(axIos);
        axIos.get(url, data).then((response) => {
          stackToken(response);
          resolve(response);
        }).catch((response) => {
          reject(response);
        })
      })
    }, apiPut(url, data){
      return new Promise((resolve,reject) => {
        setToken();
         axIos.put(url,data).then((response)=>{
           stackToken(response);
            resolve(response);
         }).catch((response)=>{
           reject(response);
         })
      })
    }
  }
};
export default http;
